/**
 * 
 */
package com.elephantgreen.xml;

import java.util.Vector;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

import com.elephantgreen.common.ElephantgreenCommon;
import com.elephantgreen.common.TruckStockData;
import com.elephantgreen.util.Util;

/**
 * @author ABC
 *
 */
public class TruckStockDataXml extends ElephantgreenXmlHandler {

	/**
	 * @param fName
	 * @param parentNodeName
	 */
	public TruckStockDataXml(String fName, String parentNodeName) {
		super(fName, parentNodeName);

	}

	/* (non-Javadoc)
	 * @see com.elephantgreen.persistance.ElephantgreenXmlHandler#getItems()
	 */
	@Override
	public Vector<ElephantgreenCommon> getItems() {


		Vector<ElephantgreenCommon> vTsd = new Vector<ElephantgreenCommon>();

		for (int temp = 0; temp < getNodes().getLength(); temp++) {

			Node nNode = getNodes().item(temp);
			if (nNode.getNodeType() == Node.ELEMENT_NODE) {

				Element element = (Element) nNode;
				
				TruckStockData tsd = new TruckStockData(
						
						Util.getAttrValue("truckExchangeId", element),
						Util.getAttrValue("username", element),
						Util.getTagValue("productCode", element), 
						Util.getTagValue("stockDate", element), 
						Util.getTagValue("bottles", element),
						Util.getTagValue("emptyBottles", element),
						Util.getTagValue("nosaleBottles", element),
						Util.getTagValue("expiredBottles", element),
						Util.getTagValue("gasoutBottles", element), 
						Util.getTagValue("crateCount", element), 
						Util.getTagValue("comments", element));

				vTsd.add(tsd);

			}
		}
		return vTsd;
	}

}
